// 添加方法
export const postBusinessListSave = (params) => {
    console.log('1111',params);
    let { businessName, columns, addForm } = params;
    let result = [];
    columns.forEach(item => {
        if (item.hasOwnProperty('key')) {
            result.push({
                fieldLength: item.fieldLength ? item.fieldLength: 64,
                fieldName: item.key,
                fieldRemark: item.title,
                fieldValue: addForm[item.key],
            })
        };
        if(item.hasOwnProperty('slot') && item.title != '操作') {
            result.push({
                fieldLength: item.fieldLength ? item.fieldLength: 64,
                fieldName: item.slot,
                fieldRemark: item.title,
                fieldValue: addForm[item.slot],
            })
        }
    });
    return {
        businessName,
        fieldItemList: result,
    };
};

// 查询方法
export const postBusinessListSearch = (params) => {
    let { searchForm, searchCondition, } = params;
    let result = [];
    searchCondition.forEach((item) => {
        result.push({
            conditionType: item.fieldValue,
            fieldName: item.fieldKey? item.fieldKey:item.fieldName,
            fieldValue: searchForm[item.fieldName],
        });
    });
    return result;
};

// 编辑方法
export const postBusinessListEdit = (params) => {
    console.log('1111',params);
    let { businessName, columns, addForm } = params;
    let result = [];
    columns.forEach(item => {
        if (item.hasOwnProperty('key')) {
            result.push({
                fieldName: item.key,
                fieldValue: addForm[item.key],
            })
        };
        if(item.hasOwnProperty('slot') && item.title != '操作') {
            result.push({
                fieldName: item.slot,
                fieldValue: addForm[item.slot],
            })
        }
    });
    return {
        businessName,
        fieldEditItemList: result,
        id:addForm.id,
    };
};

